home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 016 / noyb.arc / NOYB.ASM next >
Encoding:
Assembly Source File  |  1986-07-12  |  10.9 KB  |  238 lines

  1.   page  66,132
  2.   title NOYB.ASM - None Of Your Business - Resident Screen Blanking Program
  3. ;-----------------------------------------------------------------------------
  4. ; Program: None Of Your Business                 (NOYB.ASM)
  5. ; Version: 1.0
  6. ; Author : Gerald D. Mooshool
  7. ; Date   : July, 1986
  8. ;
  9. ; Remarks: This is a resident screen "blanker", intended to be use for  a
  10. ;          quick erasor of the current video display.  The screen will be
  11. ;          blanked out when <Alt> and NOYB's toggle key are pressed,  and
  12. ;          restored the screen when the toggle key alone it pressed.   As
  13. ;          the title explains,  the major use of this program is to allow
  14. ;          the user to quickly clear the video display when nosiy  office
  15. ;          mates try to stare over your shoulder.  It is also well suited
  16. ;          for those times when you must rush out of the office quickly
  17. ;          but do not want to exit the application you are currently using.
  18. ;-----------------------------------------------------------------------------
  19.  
  20. interrupts      segment at 0h                    ;interrupt table  segment
  21.                 org 9h  *  4                     ;interrupt number 9,
  22. keyboard_int    dw  2 dup (?)                    ;  the keyboard interrupt
  23. interrupts      ends
  24.  
  25. code            segment para public 'code'
  26.                 assume  cs:code
  27.                 org     100h
  28. begin:          jmp initialize
  29.  
  30. recursion_flag  db  0                            ;flag used to check for
  31.                                                  ;  recursive entry
  32.  
  33. toggle_keyscan  db  44                           ;keyboard scan code for
  34.                                                  ;  'Z' and 'z' key.
  35.  
  36. video_mode      db  ?                            ;active video mode
  37. video_page      db  ?                            ;active video page
  38. cursor_pos      dw  ?                            ;cursor position
  39. cursor_type     dw  ?                            ;cursor scan  lines
  40. save_screen     db  4000 dup (?)                 ;save screen image buffer
  41.  
  42. mono_segment    dw  0b000h                       ;mono segment address
  43. cga_segments    dw  0b800h,0b900h,0ba00h,0bb00h  ;cga page segments
  44.  
  45. tsr_message     db  13,10                        ;tell them its loaded
  46.                 db  213,40 dup(205),184,13,10
  47.                 db  179,' NOYB  (V1.0A)         Loaded  Resident ',179,13,10
  48.                 db  179,'                                        ',179,13,10
  49.                 db  179,' Press The <Alt> and <Z> Keys To Toggle ',179,13,10
  50.                 db  212,40 dup(205),190,13,10,'$'
  51.  
  52. old_kb_int      label dword                      ;segment and offset of the
  53. old_keyboard_int    dw  2 dup (?)                ;  keyboard interrupt
  54.  
  55.  
  56.   page
  57. ;-----------------------------------------------------------------------------
  58. ; When loaded resident, this now becomes the entry point for the keyboard
  59. ; interrupt.
  60. ;-----------------------------------------------------------------------------
  61. main         proc    near
  62.              sti                                 ;enable software interrupts
  63.              push    ax                          ;save all registers
  64.              push    bx
  65.              push    cx
  66.              push    dx
  67.              push    si
  68.              push    di
  69.              push    ds
  70.              push    es
  71.  
  72.              pushf                               ;push flags for call to the
  73.              call    old_kb_int                  ;  old kbd interrupt
  74.              mov     ah,2                        ;check shift status of keys
  75.              int     16h
  76.              and     al,8                        ;test if bit 3 is set
  77.              cmp     al,8                        ;8 = <Alt> depressed.
  78.              jne     exit
  79.              mov     ah,1                        ;check keyboard buffer to see
  80.              int     16h                         ;  if something is in it
  81.              jz      exit                        ;0  = nothing in buffer
  82.              cmp     ah,toggle_keyscan           ;44 = the 'Z' key
  83.              jne     exit
  84.              mov     ah,0                        ;now, read the buffer to clear
  85.              int     16h                         ;  it of the toggle key
  86.              jmp     start_program
  87.  
  88.   page
  89. ;-----------------------------------------------------------------------------
  90. ; Return to callers program
  91. ;-----------------------------------------------------------------------------
  92. exit:        pop     es                          ;restore callers registers
  93.              pop     ds
  94.              pop     di
  95.              pop     si
  96.              pop     dx
  97.              pop     cx
  98.              pop     bx
  99.              pop     ax
  100.              iret                                ;interrupt return
  101.  
  102.  
  103.   page
  104. ;-----------------------------------------------------------------------------
  105. ; When this program's toggle keys are pressed, program execution will continue
  106. ; here.
  107. ;-----------------------------------------------------------------------------
  108. start_program:
  109.              push    cs                          ;set ds to cs segment
  110.              pop     ds
  111.              push    cs                          ;set es to cs segment
  112.              pop     es
  113.  
  114.              cmp     recursion_flag,0            ;check for recursion
  115.              jne     exit
  116.  
  117. get_video_state:
  118.              mov     ah,15                       ;get video information and
  119.              int     10h                         ;  determine if the caller
  120.              cmp     al,2                        ;  is in a video mode which
  121.              je      video_mode_ok               ;  NOYB will operate in.
  122.              cmp     al,3                        ;  if not, just bypass the
  123.              je      video_mode_ok               ;  request by returning to
  124.              cmp     al,7                        ;  calling program.
  125.              jne     exit
  126.  
  127. video_mode_ok:
  128.              mov     recursion_flag,1            ;NOYB is toggled.....set flag
  129.              mov     video_mode,al               ;save callers video mode
  130.              mov     video_page,bh               ;save callers video page
  131.  
  132.              mov     ah,3                        ;get caller's cursor state
  133.              int     10h
  134.              mov     cursor_pos,dx               ;save callers cursor position
  135.              mov     cursor_type,cx              ;save callers cursor type
  136.  
  137.              mov     ax,mono_segment             ;lets assume mode mono
  138.              cmp     video_mode,7                ;is it mode mono?
  139.              je      save_callers_screen         ;yes....carry on
  140.              mov     bx,0                        ;no.....use video page as a
  141.              mov     bl,video_page               ;  pointer into the table of
  142.              mov     ax,cga_segments [bx]        ;  cga page segments
  143.  
  144. save_callers_screen:
  145.              mov     ds,ax                       ;ds = current video segment
  146.              mov     si,0                        ;si = offset into video seg
  147.              push    cs
  148.              pop     es                          ;es = current code segment
  149.              lea     di,save_screen              ;di = points to data area
  150.              mov     cx,4000                     ;save 4000 bytes from the
  151.              cld                                 ;  video buffer into our
  152.              rep     movsb                       ;  save buffer
  153.  
  154.              mov     ah,1                        ;turn the cursor off
  155.              mov     cx,2000h
  156.              int     10h
  157.  
  158.              mov     ax,mono_segment
  159.              cmp     video_mode,7
  160.              je      clear_screen
  161.              mov     bx,0
  162.              mov     bl,video_page
  163.              mov     ax,cga_segments [bx]
  164.  
  165. clear_screen:
  166.              mov     es,ax                      ;es = current video segment
  167.              mov     di,0                       ;di = offset into video seg
  168.              mov     ax,0720h                   ;char & attrib to clear with
  169.              mov     cx,2000                    ;2000 words (char & attrib)
  170.              cld                                ;  to move to the video area
  171.              rep     stosw
  172.  
  173. wait_for_toggle:
  174.              mov     ah,0                       ;continue to loop until NOYB
  175.              int     16h                        ;  toggle key is pressed by
  176.              cmp     ah,toggle_keyscan          ;  its self.  video remains
  177.              jne     wait_for_toggle            ;  cleared.
  178.  
  179. restore_callers_screen:
  180.              mov     ax,mono_segment            ;when toggle key is pressed
  181.              cmp     video_mode,7               ;  the callers screen and
  182.              je      rcs1                       ;  cursor are restored.
  183.              mov     bx,0
  184.              mov     bl,video_page
  185.              mov     ax,cga_segments [bx]
  186.  
  187. rcs1:        mov     es,ax                      ;here we will restore the
  188.              mov     di,0                       ;  callers screen with the
  189.              push    cs                         ;  image of it that was saved
  190.              pop     ds                         ;  in our data buffer
  191.              lea     si,save_screen
  192.              mov     cx,4000
  193.              cld
  194.              rep     movsb
  195.  
  196.              mov     ah,1                        ;reset cursor to the way it
  197.              mov     cx,cursor_type              ;  appeared on the callers
  198.              int     10h                         ;  screen
  199.  
  200.              mov     recursion_flag,0            ;reset flag for next time
  201.              jmp     exit
  202. main         endp
  203.  
  204.   page
  205. ;-----------------------------------------------------------------------------
  206. ; Initialization code will change the interrupt vector table and load resident
  207. ;-----------------------------------------------------------------------------
  208. initialize   proc    near
  209.              assume  ds:code, es:code
  210.  
  211.              mov     ah,9                        ;send loaded message
  212.              lea     dx,tsr_message
  213.              int     21h
  214.  
  215.              mov     recursion_flag,0            ;intialize flag to 0='no'
  216.  
  217.              mov     ax,interrupts
  218.              mov     ds,ax                       ;ds = interrupts segment adr
  219.              assume  ds:interrupts
  220.  
  221.              mov     ax,keyboard_int
  222.              mov     old_keyboard_int,ax         ;save old vector address
  223.              mov     ax,keyboard_int[2]
  224.              mov     old_keyboard_int[2],ax
  225.  
  226.              cli                                 ;clear interrupts
  227.              mov     keyboard_int,offset main    ;install new vector
  228.              mov     keyboard_int[2],cs
  229.              sti                                 ;start interrupts
  230.  
  231.              mov     dx,offset initialize        ;dx = end of tsr code
  232.              int     27h                         ;terminate and stay resident
  233. initialize   endp
  234.  
  235.  
  236. code         ends                                ;end of code segment
  237.              end     begin                       ;end of program
  238.